<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:Hyperbolic"
    xmlns:cv="clr-namespace:Hyperbolic.Converters">

    <cv:LocationConverter x:Key="locationConverter" />
    <cv:ScaleConverter x:Key="scaleConverter" />
    <cv:OpacityConverter x:Key="opacityConverter" />

    <Style TargetType="{x:Type local:TreeView}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:TreeView}">
                    <Border BorderBrush="LightGray" BorderThickness="1" CornerRadius="15"
                            Background="Beige">
                        <ItemsPresenter/>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="ItemsPanel" >
            <Setter.Value>
                <ItemsPanelTemplate>
                    <local:ItemsPanel 
                        Background="Transparent"                        
                        Width="{Binding Path=Model.ContainerBound.X}" 
                        Height="{Binding Path=Model.ContainerBound.Y}"/>
                </ItemsPanelTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="ItemTemplate">
            <Setter.Value>
                <DataTemplate>
                    <Border 
                        Background="sc#1, 0.979549646, 0.6541397, 0.0275757164"
                        BorderThickness="1" 
                        BorderBrush="Black" 
                        CornerRadius="6" 
                        Padding="5">
                        <TextBlock Text="{Binding Path=Node.Name}"/>
                    </Border>
                </DataTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="ItemContainerStyle">
            <Setter.Value>
                <Style TargetType="{x:Type ContentPresenter}">
                    <Style.Triggers>
                        <Trigger Property="Control.IsMouseOver" Value="True">
                            <Setter Property="Control.ToolTip" Value="{Binding Path=Node.Description}"/>
                        </Trigger>
                    </Style.Triggers>
                    <Setter Property="Control.MinWidth" Value="30"/>
                    <Setter Property="Control.MaxWidth" Value="160"/>
                    <Setter Property="Canvas.Left">
                        <Setter.Value>
                            <MultiBinding Converter="{StaticResource locationConverter}">
                                <Binding Path="ScreenCoordinates.X"/>
                                <Binding RelativeSource="{RelativeSource Self}" Path="ActualWidth"/>
                            </MultiBinding>
                        </Setter.Value>
                    </Setter>
                    <Setter Property="Canvas.Top">
                        <Setter.Value>
                            <MultiBinding Converter="{StaticResource locationConverter}">
                                <Binding Path="ScreenCoordinates.Y"/>
                                <Binding RelativeSource="{RelativeSource Self}" Path="ActualHeight"/>
                            </MultiBinding>
                        </Setter.Value>
                    </Setter>
                    <Setter Property="Opacity">
                        <Setter.Value>
                            <MultiBinding Converter="{StaticResource opacityConverter}">
                                <Binding Path="EuclidianCoordinates"/>
                                <Binding Path="."/>
                            </MultiBinding>
                        </Setter.Value>
                    </Setter>
                    <Setter Property="RenderTransformOrigin" Value="0.5,0.5"/>
                    <Setter Property="RenderTransform">
                        <Setter.Value>
                            <ScaleTransform>
                                <ScaleTransform.ScaleX>
                                    <MultiBinding Converter="{StaticResource scaleConverter}" ConverterParameter="ScaleX">
                                        <Binding Path="EuclidianCoordinates"/>
                                        <Binding Path="."/>
                                    </MultiBinding>
                                </ScaleTransform.ScaleX>
                                <ScaleTransform.ScaleY>
                                    <MultiBinding Converter="{StaticResource scaleConverter}" ConverterParameter="ScaleY">
                                        <Binding Path="EuclidianCoordinates"/>
                                        <Binding Path="."/>
                                    </MultiBinding>
                                </ScaleTransform.ScaleY>
                            </ScaleTransform>
                        </Setter.Value>
                    </Setter>
                </Style>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>
